#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

void func()
{
  char* retval="nihao~!";
  pthread_exit(retval);
}
void* entry(void *arg)
{
  sleep(3);
  func();
  while(1)
  {
    printf("%s--child thread!\n",arg);
    sleep(1);
  }
  return NULL;
}
int main()
{
  pthread_t tid;
  char *buf="你好啊!";
  int ret=pthread_create(&tid,NULL,entry,(char*)buf);
  if(ret!=0)
  {
    printf("thread create error!\n");
    return 0;
  }
  pthread_detach(tid);

  printf("tid:%p\n",tid);
  //sleep(4);
  //pthread_cancel(tid);
  
  void *retval;
  pthread_join(tid,&retval);
  printf("tid:%p----%s\n",tid,retval);

  while(1)
  {
    printf("main thread!\n");
    sleep(1);
  }
  return 0;
}
